import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import com.jgoodies.forms.factories.*;
/*
 * Created by JFormDesigner on Tue Dec 20 10:40:27 CST 2022
 */



/**
 * @author 1
 */
public class cal extends JFrame implements ActionListener {
    public cal() {
        initComponents();
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        DefaultComponentFactory compFactory = DefaultComponentFactory.getInstance();
        panel1 = new JPanel();
        label1 = compFactory.createLabel("\u8fb9A\uff1a");
        A = new JTextField();
        label2 = compFactory.createLabel("\u8fb9B\uff1a");
        B = new JTextField();
        label3 = compFactory.createLabel("\u8fb9C\uff1a");
        C = new JTextField();
        button1 = new JButton();
        button1.addActionListener(this);
        scrollPane1 = new JScrollPane();
        textArea1 = new JTextArea();

        //======== this ========
        setMinimumSize(new Dimension(600, 500));
        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());

        //======== panel1 ========
        {
            panel1.setLayout(new GridLayout(1, 5));
            panel1.add(label1);
            panel1.add(A);
            panel1.add(label2);
            panel1.add(B);
            panel1.add(label3);
            panel1.add(C);

            //---- button1 ----
            button1.setText("\u8ba1\u7b97\u9762\u79ef");
            panel1.add(button1);
        }
        contentPane.add(panel1, BorderLayout.NORTH);

        //======== scrollPane1 ========
        {
            scrollPane1.setViewportView(textArea1);
        }
        contentPane.add(scrollPane1, BorderLayout.CENTER);
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JPanel panel1;
    private JLabel label1;
    private JTextField A;
    private JLabel label2;
    private JTextField B;
    private JLabel label3;
    private JTextField C;
    private JButton button1;
    private JScrollPane scrollPane1;
    private JTextArea textArea1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
    public static void main(String[] args) {
        cal cal = new cal();
        cal.setVisible(true);
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource()==button1) {
            int a=Integer.parseInt(A.getText());
            int b=Integer.parseInt(B.getText());
            int c=Integer.parseInt(C.getText());
            int p=(a+b+c)/2;
            double S=Math.sqrt(p*(p-a)*(p-b)*(p-c));
            textArea1.append("三角形面积："+S);
        }
    }
}
